/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.services;

import java.util.List;
import tpdisenio2009.model.beans.TournamentDate;
import tpdisenio2009.model.dao.TournamentDateDAO;

/**
 *
 * @author DeuterioX
 */
public class TournamentDateService {

    private final TournamentDateDAO tournamentDateDAO;

    public TournamentDateService() {

        tournamentDateDAO = new TournamentDateDAO();
    }

    public TournamentDate getFirstOpenTournamentDate() {
        List<TournamentDate> dates = tournamentDateDAO.getAllOrdered();
        for ( TournamentDate date : dates ) {
            if ( date.getState().equals( TournamentDate.OPEN_DATE ) ) {
                return date;
            }
        }
        return dates.get( dates.size() -1 );
    }
    
    public List<TournamentDate> getClosedTournamentDates() {
        return tournamentDateDAO.getClosedTournamentDates();
    }

    public List<TournamentDate> getDates() {
        return tournamentDateDAO.getAll();
    }

    public void update( TournamentDate date ) {
        tournamentDateDAO.update( date );
    }

}
